const returns = require('./unit');
const authentication = async (ctx, next)=>{
    let authUrls = ['/prod','/addr', '/cart'];
    if(authUrls.indexOf(ctx.request.path) > -1){
        if(ctx.session.uid||ctx.session.admin){
            await next();
        }else {
            ctx.body = returns(-10000,'请登录', ctx.request.url);
        }
    }else {
        await next();
    }

};
module.exports = authentication;
